<template>
  <div class="list">
    <el-table
      :data="tableData"
      border
      height="200"
      show-summary
      style="width: 50%; margin-top: 20px; margin: 100px auto"
    >
      <el-table-column type="index" label="ID" width="180"> </el-table-column>
      <el-table-column prop="addressname" label="银行地址"> </el-table-column>
      <el-table-column prop="longitude" label="经度"> </el-table-column>
      <el-table-column prop="latitude" label="纬度"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getAddress, deleteAddress } from "@/api/address";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      //获取地址列表信息接口
      getAddress()
        .then((res) => {
          this.tableData = res.data.records;
          // console.log(res, "res");
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleDelete(row) {
      console.log(row);
      //这个删除地址
      deleteAddress([row.addressid])
        .then((res) => {
          // console.log(res);
          this.init();
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style scoped>
</style>